package br.senai.modelo.impl;

import java.util.List;

import br.senai.entidade.Cliente;
import br.senai.modelo.ClienteDAO;

public class ClienteDAOImpl extends BaseDAOImpl implements ClienteDAO {

	@SuppressWarnings("unchecked")
	@Override
	public List<Cliente> getLista() {
		return super.entityManager.createNamedQuery("allClients").getResultList();
	}

	@SuppressWarnings("unchecked")
	@Override
	public Cliente buscarClientePorCnpj(String cnpj) {
		List<Cliente> clientes =  super.entityManager.createNamedQuery("selectClientByCnpj").setParameter("cnpj", cnpj).getResultList();
		return clientes != null && clientes.size() > 0 ? clientes.get(0) : null;
	}

}